package {
	import com.guavestudios.fnfo.Fnfo;
	import com.guavestudios.fnfo.utils.FnfoErrorHandler;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	/**
	 * ...
	 * @author maze
	 */
	public class Main extends Sprite {
		
		public static var VERSION:String = "0.0.1";
		[Embed(source='../scripts/version.txt',mimeType="application/octet-stream")]
		public static var VERSION_INFO:Class;
		
		public function Main():void {
			//FnfoErrorHandler.active = true;
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, FnfoErrorHandler.addHandle(init));
			
		}
		
		private function init(e:Event = null):void {
			removeEventListener(Event.ADDED_TO_STAGE, FnfoErrorHandler.removeHandle(init));
			// entry point
			
			
			
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			
			Fnfo.initialize(this, { version:VERSION, versioninfo:FnfoVersion_fnfo.VERSION_FILE } );
			
			var x:Number, y:Number;
			for (var i:int = 0,ilen:int=30; i < ilen; i++) {
				x = Math.random() * stage.stageWidth;
				y = Math.random() * stage.stageHeight;
				
				graphics.beginFill(0xFFFFFF * Math.random());
				graphics.drawRect(x, y, 20, 20);
				graphics.endFill();
			}
			//stage.addEventListener(MouseEvent.CLICK, FnfoErrorHandler.addHandle(this_click));
		}
		
		private function this_click(e:MouseEvent):void {
			throw new Error("lalall");
		}
		
	}
	
}